package com.usian.article.controller;

import com.usian.article.ApArticleControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.article.dtos.ArticleInfoDto;
import com.usian.model.article.pojos.ApArticle;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController implements ApArticleControllerApi {


    @Autowired
    private ApArticleService apArticleService;


    /**
     * 保存文章表
     *
     * @param apArticle
     * @return
     */
    @Override
    @PostMapping("/save")
    public ApArticle saveApArticle(@RequestBody ApArticle apArticle) {
        return apArticleService.saveArticle(apArticle);
    }

    /**
     * app查询默认列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @Override
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.findArcitle(dto);
    }

    /**
     * app查询 上拉加载更多
     * @param dto
     * @return
     */
    @PostMapping("/loadmore")
    @Override
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.findArcitle(dto);
    }

    /**
     * app查询 下拉加载最新
     * @param dto
     * @return
     */
    @PostMapping("/loadnew")
    @Override
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.findArcitle(dto);
    }


    /**
     * app文章查询详情
     *
     * @param dto
     * @return
     */
    @PostMapping("/load_article_info")
    @Override
    public ResponseResult load_article_info(@RequestBody ArticleInfoDto dto) {
        return apArticleService.findArticleInfo(dto);
    }


}
